<?php

/**
 * @name 消费
 */
class Controller_Consume extends \Modules\Admin\Controllers\Controller {

    /**
     * @name 消费列表
     */
    public function indexAction() {

    }
    /**
     * @name 搜索消费列表
     */
    public function searchAction() {
        $param = [];
        if($this->getParams('uid')){
            $param['uid'] = $this->getParams('uid');
        }
        if($this->getParams('tid')){
            $param['tid'] = $this->getParams('tid');
        }

        $obj = new \Data\Consume\Consume();
        $ret = $obj->getDataTable($param,[],['cid'=>'desc']);

        if($ret['data']){
            $subject_obj = new \Data\Subject\Subject();
            $question_obj = new \Data\Question\Question();
            foreach ($ret['data'] as $key=>$value){
                $s_info = $subject_obj->getSubjInfoById($value['subject']);
                $q_info = $question_obj->get($value['question']);
                $ret['data'][$key]['subject'] = $s_info['name'];
                $ret['data'][$key]['question'] = $q_info['name'];
            }
        }

        $this->response = $ret;
    }


}
